Experiments
In this lesson, we'll look at some experiments that you can try out with SSI using ESI.
We'll cover the following
/
- docker-compose.yml
-
A microservice that simply displays a static HTML page can serve as an example.
-
The new microservice should integrate header, navigation bar, and footer of the common microservice via ESI tags.
-
Package the microservice as a Docker image and reference it in
docker-compose.yml
. There you can also determine the name of the Docker container. -
The microservice has to be accessible via Varnish. To achieve that, you have to integrate a new backend with the name of the Docker container in
default.vcl
and adapt the routing invcl_recv()
. -
Now you should be able to access the new microservice at http:localhost:8080/name if the Docker containers run on the local computer and the new service is configured in Varnish’s routing with
name
. The ESI tags should have been replaced by HTML code. -
The Go application returns only a dynamic HTML fragment – the navigation bar with the current time. Instead of the Go application, a web server can also deliver static pages. For example, replace the Go application with an Apache httpd server that delivers the HTML fragments and the Bootstrap library. The time does not necessarily have to be displayed in the navigation bar, so a static HTML fragment is all that is needed.
-
Change the caching so that the pages are immediately invalidated when new orders are received. You can, for example, use matching HTTP headers as explained in a chapter of the Varnish book. An alternative is to remove objects directly from the cache. The Varnish book also contains a chapter on this option.
-
Replace the Varnish cache in the example with Squid, which also implements ESI.
-
Replace ESI with SSI and replace the Varnish cache with an Apache httpd or nginx.
-
What happens if the web servers fail? Simulate the failure with
docker-compose up --scale common=0
ordocker-compose up --scale order=0
. Which parts of the web page still work? Is it still possible to place orders, for example?
In the next lesson, we’ll look at a quick chapter conclusion.